package com.aaa.hospital.controller;

import com.aaa.hospital.pojo.domain.AliPayBean;
import com.aaa.hospital.service.PayService;
import com.alipay.api.AlipayApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：zzg
 * @description：
 * @date ：2022/2/21 16:00
 */
@Controller
@RequestMapping("/ali")
public class OrderController {


    @Autowired
    private PayService payService;

    @RequestMapping("/pay")
    @ResponseBody
    public String alipay(String outTradeNo, String subject, String totalAmount) throws AlipayApiException {

        AliPayBean alipayBean = new AliPayBean();
        alipayBean.setOut_trade_no(outTradeNo);
        alipayBean.setSubject(subject);
        alipayBean.setTotal_amount(totalAmount);


        return payService.aliPay(alipayBean);
    }

    @RequestMapping("/success")
    @ResponseBody
    public String success(){
        return "交易成功！";
    }

    @RequestMapping(value = "/index")
    public String payCoin(){
        return "index.html";
    }
}